﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Anagramme.Converters;
using System.Windows;

namespace Anagramme.Common.Tests.Converters
{
    [TestClass]
    public class BooleanToVisibilityConverterTests
    {
        [TestMethod]
        public void ConvertFalseWitoutParameterReturnsCollapsed()
        {
            Visibility expected = Visibility.Collapsed;
            BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();
            
            object actual = converter.Convert(false, null, null, null);
            
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ConvertTrueWitoutParameterReturnsVisible()
        {
            Visibility expected = Visibility.Visible;
            BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();

            object actual = converter.Convert(true, null, null, null);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ConvertNullWitoutParameterReturnsCollapse()
        {
            Visibility expected = Visibility.Collapsed;
            BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();

            object actual = converter.Convert(null, null, null, null);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ConvertFalseWithFalseParameterReturnsCollapsed()
        {
            Visibility expected = Visibility.Collapsed;
            BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();

            object actual = converter.Convert(false, null, false, null);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ConvertTrueWithFalseParameterReturnsVisible()
        {
            Visibility expected = Visibility.Visible;
            BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();

            object actual = converter.Convert(true, null, false, null);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ConvertNullWithFalseParameterReturnsCollapsed()
        {
            Visibility expected = Visibility.Collapsed;
            BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();

            object actual = converter.Convert(null, null, false, null);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ConvertFalseWithTrueParameterReturnsHidden()
        {
            Visibility expected = Visibility.Hidden;
            BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();

            object actual = converter.Convert(false, null, true, null);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ConvertTrueWithTrueParameterReturnsVisible()
        {
            Visibility expected = Visibility.Visible;
            BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();

            object actual = converter.Convert(true, null, true, null);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ConvertNullWithTrueParameterReturnsHidden()
        {
            Visibility expected = Visibility.Hidden;
            BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();
            
            object actual = converter.Convert(null, null, true, null);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ConvertBackCollapsedReturnsFalse()
        {
            bool expected = false;
            BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();

            object actual = converter.ConvertBack(Visibility.Collapsed, null, null, null);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ConvertBackHiddenReturnsFalse()
        {
            bool expected = false;
            BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();

            object actual = converter.ConvertBack(Visibility.Hidden, null, null, null);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ConvertBackVisibleReturnsTrue()
        {
            bool expected = true;
            BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();

            object actual = converter.ConvertBack(Visibility.Visible, null, null, null);

            Assert.AreEqual(expected, actual);
        }
    }
}
